<template>
  <el-dialog title="任务详情" :visible.sync="showForm" @close="close" width="60%"  append-to-body>
    <el-form :model="form" :rules="rules" ref="form" label-width="100px" class="demo-ruleForm">
      <el-row>
        <el-col :span="24">
          <el-form-item label="任务内容" prop="title">
            <el-input
              type="textarea"
              :rows="4"
              placeholder="请输入任务内容"
              v-model="form.title">
            </el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="24">
          <el-form-item label="备注" prop="bz">
            <el-input
              type="textarea"
              :rows="4"
              placeholder="请输入备注"
              v-model="form.bz">
            </el-input>
          </el-form-item>
        </el-col>
      </el-row>
<!--      <el-row>-->
<!--        <el-col :span="24">-->
<!--          <el-form-item label="备注" prop="bz">-->
<!--            <el-table-->
<!--              :data="fjList"-->
<!--              border-->
<!--              style="width: 100%">-->
<!--              <el-table-column-->
<!--                prop="fjname"-->
<!--                label="附件名称"-->
<!--                width="180">-->
<!--              </el-table-column>-->
<!--            </el-table>-->
<!--          </el-form-item>-->
<!--        </el-col>-->
<!--      </el-row>-->
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button :loading="buttonLoading" type="primary" @click="submitForm">确 定</el-button>
      <el-button @click="close">关 闭</el-button>
    </div>
  </el-dialog>
</template>

<script>
import { updateTodo } from '@/api/gd/todo'
import { allListFj } from '@/api/gd/fj'

export default {
  name: 'updateForm',
  props: {
    showForm: {
      type: Boolean
    },
    formInfo: {
      type: Object
    }
  },
  data() {
    return {
      form: {},
      rules: {
        title: [
          { required: true, message: '请输入任务内容', trigger: 'blur' },
        ]
      },
      buttonLoading: false,
      fjList: []
    };
  },
  async created() {
    this.form = this.formInfo
    // 判断附件id查询附件列表
    // if (this.form.fjid !== undefined && this.form.fjid !== null && this.form.fjid !== "") {
    //   await allListFj(this.form.fjid).then(res => {
    //     this.fjList = res
    //     console.log("this.fjList", this.fjList)
    //   })
    // }
  },
  methods: {
    submitForm() {
      this.$refs.form.validate((valid) => {
        if (valid) {
          this.buttonLoading = true
          updateTodo(this.form).then(res => {
            if (res.code === 200) {
              this.$message.success("修改成功！")
            }
          }).finally( res => {
            this.buttonLoading = false
            this.$emit("closeForm")
          })
        }
      });
    },
    close() {
      this.$emit("closeForm")
    }
  }

}
</script>

<style scoped>

</style>
